<template>
  <div class="song-card-desc">
    <div class="bg"
      :style="`background: url(${item?.coverImgUrl}?param=330y330);background-size: cover;background-position: center;`">
    </div>
    <div class="card">
      <div class="cover">
        <img :src="item?.coverImgUrl + '?imageView=1&type=webp&thumbnail=247x0'" alt="">
      </div>
      <div class="volume">
        <div class="icon-erji"></div>
        <span>{{ formatCount }}</span>
      </div>

      <div class="label">{{ item?.highQuality ? '精品' : '' }}歌单</div>

    </div>

    <div class="right">
      <h2 class="desc">{{ item?.name }}</h2>

      <div class="author">
        <div class="img">
          <img :src="item?.creator?.avatarUrl + '?imageView=1&type=webp&thumbnail=61x0'">
          <div class="badge"></div>
        </div>

        <span>{{ item?.creator?.nickname }}</span>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: Object,
  },
  data() {
    return {

    }
  },

  computed: {
    formatCount() {
      let count = this.item?.playCount
      let m = (count / 10000).toFixed(1)
      let b = (m / 10000).toFixed(1)
      if (m < 0) {
        return count
      } else if (m < 10000) {
        return (m === Math.floor(m) ? Math.floor(m) : m) + '万'
      }
      return (b === Math.floor(b) ? Math.floor(b) : b) + '亿'
    }
  }
}
</script>
<style lang='scss' scoped>
$red: rgba(217, 48, 48, .8);

.song-card-desc {
  position: relative;
  display: flex;
  height: 126px;
  padding: 30px 10px 30px 15px;
  overflow: hidden;

  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(20px);
    transform: scale(1.3);
  }

  .right {
    margin-left: 16px;
    padding-top: 3px;
    color: #fff;


    .desc {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      padding-top: 2px;
      font-size: 17px;
      font-weight: 500;
      line-height: 1.2;
    }

    .author {
      display: flex;
      align-items: center;

      .img {
        position: relative;
        width: 30px;
        height: 30px;
        margin-right: 5px;

        img {
          width: 100%;
          border-radius: 50%;
        }

        .badge {
          position: absolute;
          bottom: -5px;
          right: 0;
          width: 12px;
          height: 12px;
          background: url('https://s3.music.126.net/mobile-new/img/usericn_2x.png?6423c0681bfb3358d5c684c9b998e412=') no-repeat;
          background-size: 75px auto;
        }
      }

      span {
        font-size: 14px;
      }
    }
  }
}

.card {
  position: relative;
  width: 126px;
  height: 126px;

  .cover {
    width: 126px;
    height: 126px;

    img {
      width: 100%;
    }
  }

  .volume {
    position: absolute;
    top: 5px;
    right: 2px;
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 12px;

    .icon-erji {
      width: 12px;
      height: 12px;
      margin-right: 2px;
      background: url('../../images/palyCount.svg') no-repeat;
      background-size: contain;
    }
  }

  .label {
    position: absolute;
    top: 15px;
    left: 0;
    padding: 0 8px;
    background-color: $red;
    font-size: 12px;
    color: #fff;
    border-radius: 0 8px 8px 0;
  }

}
</style>